
#include "nx_api.h"

#ifdef __PRODUCT_NETXDUO__
#include "netx_mdns_test.h"

/* Frame (85 bytes) */
static const unsigned char pkt1[85] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x00, 0x11, /* ..^..... */
0x22, 0x33, 0x44, 0x57, 0x08, 0x00, 0x45, 0x00, /* "3DW..E. */
0x00, 0x47, 0x00, 0x07, 0x40, 0x00, 0xff, 0x11, /* .G..@... */
0x90, 0x61, 0x0a, 0x00, 0x00, 0x42, 0xe0, 0x00, /* .a...B.. */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0x33, /* .......3 */
0xd8, 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x43, /* .......C */
0x68, 0x65, 0x6e, 0x62, 0x6f, 0x2d, 0x50, 0x43, /* henbo-PC */
0x04, 0x5f, 0x73, 0x6d, 0x62, 0x04, 0x5f, 0x74, /* ._smb._t */
0x63, 0x70, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, /* cp.local */
0x00, 0x00, 0xff, 0x00, 0x01                    /* ..... */
};

/* Frame (269 bytes) */
static const unsigned char pkt2[269] = {
0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x18, 0x03, /* ..^..... */
0x73, 0x33, 0xc1, 0xbd, 0x08, 0x00, 0x45, 0x00, /* s3....E. */
0x00, 0xff, 0x17, 0x8d, 0x00, 0x00, 0xff, 0x11, /* ........ */
0x01, 0x51, 0xc0, 0xa8, 0x00, 0x6c, 0xe0, 0x00, /* .Q...l.. */
0x00, 0xfb, 0x14, 0xe9, 0x14, 0xe9, 0x00, 0xeb, /* ........ */
0x67, 0xea, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, /* g....... */
0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x09, 0x43, /* .......C */
0x68, 0x65, 0x6e, 0x62, 0x6f, 0x2d, 0x50, 0x43, /* henbo-PC */
0x04, 0x5f, 0x73, 0x6d, 0x62, 0x04, 0x5f, 0x74, /* ._smb._t */
0x63, 0x70, 0x05, 0x6c, 0x6f, 0x63, 0x61, 0x6c, /* cp.local */
0x00, 0x00, 0x21, 0x80, 0x01, 0x00, 0x00, 0x00, /* ..!..... */
0x78, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x01, /* x....... */
0xbd, 0x09, 0x43, 0x68, 0x65, 0x6e, 0x62, 0x6f, /* ..Chenbo */
0x2d, 0x50, 0x43, 0xc0, 0x20, 0xc0, 0x0c, 0x00, /* -PC. ... */
0x10, 0x80, 0x01, 0x00, 0x00, 0x11, 0x94, 0x00, /* ........ */
0x23, 0x11, 0x6e, 0x65, 0x74, 0x62, 0x69, 0x6f, /* #.netbio */
0x73, 0x3d, 0x43, 0x48, 0x45, 0x4e, 0x42, 0x4f, /* s=CHENBO */
0x2d, 0x50, 0x43, 0x10, 0x64, 0x6f, 0x6d, 0x61, /* -PC.doma */
0x69, 0x6e, 0x3d, 0x57, 0x4f, 0x52, 0x4b, 0x47, /* in=WORKG */
0x52, 0x4f, 0x55, 0x50, 0xc0, 0x37, 0x00, 0x01, /* ROUP.7.. */
0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x04, /* .....x.. */
0xc0, 0xa8, 0x00, 0x6c, 0xc0, 0x37, 0x00, 0x1c, /* ...l.7.. */
0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x10, /* .....x.. */
0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /*  ....... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, /* .......1 */
0xc0, 0x37, 0x00, 0x1c, 0x80, 0x01, 0x00, 0x00, /* .7...... */
0x00, 0x78, 0x00, 0x10, 0xfe, 0x80, 0x00, 0x00, /* .x...... */
0x00, 0x00, 0x00, 0x00, 0x01, 0x59, 0x44, 0x79, /* .....YDy */
0xe1, 0x0a, 0xd7, 0xf4, 0xc0, 0x37, 0x00, 0x2f, /* .....7./ */
0x80, 0x01, 0x00, 0x00, 0x00, 0x78, 0x00, 0x08, /* .....x.. */
0xc0, 0x37, 0x00, 0x04, 0x40, 0x00, 0x00, 0x08, /* .7..@... */
0xc0, 0x0c, 0x00, 0x2f, 0x80, 0x01, 0x00, 0x00, /* .../.... */
0x00, 0x78, 0x00, 0x09, 0xc0, 0x0c, 0x00, 0x05, /* .x...... */
0x00, 0x00, 0x80, 0x00, 0x40                    /* ....@ */
};

static MDNS_QUERY_INFO mdns_query = {"Chenbo-PC", "_smb._tcp", NX_NULL};

MDNS_TEST_SEQ mdns_continuous_query_unique_answer[] = {
    {TITLE, "Continuous query unique answer", 30, 0},
    {WAIT, NX_NULL, 0, 5},
    {DUMP, NX_NULL, 0, 0},
    
    {MDNS_QUERY, (char*)&mdns_query, 0, 0},
    {MDNS_CHECK_DATA_V4, (char*)&pkt1[0], sizeof(pkt1), 5},
    {INJECT, (char*)&pkt2[0], sizeof(pkt2), 0},

    /* No more queries are expected. */
    {MDNS_REJECT_ANY_V4, NX_NULL, MDNS_FLAG_QUERY, 2},

    /* Delete the query. */
    {MDNS_QUERY_DELETE, NX_NULL, 0, 0},

    /* Since we have known a unique answer, no more queries are expected. */
    {MDNS_QUERY, (char*)&mdns_query, 0, 0},
    {MDNS_REJECT_ANY_V4, NX_NULL, MDNS_FLAG_QUERY, 2},
};

int mdns_continuous_query_unique_answer_size = sizeof(mdns_continuous_query_unique_answer) / sizeof(MDNS_TEST_SEQ);

#endif /* __PRODUCT_NETXDUO__  */
